package com.javafive;

import java.io.*;

public class Demo16 {
    public static void main(String[] args) throws Exception {

        String path="E:\\webWork\\javaKh62Demo\\src\\com\\javafive\\txt\\1.txt";
        /*OutputStream outputStream = new FileOutputStream(path);
        ObjectOutputStream  objectOutputStream = new ObjectOutputStream(outputStream);

        User user = new User();
        user.setId(1);
        user.setName("lisi");
        user.setPassword("123");

        objectOutputStream.flush();
        objectOutputStream.writeObject(user);*/

        InputStream inputStream = new FileInputStream(path);
        ObjectInputStream  objectInputStream = new ObjectInputStream(inputStream);
        Object object = objectInputStream.readObject();
        User user =null;
        if(object instanceof User){
            user=(User)object;
        }
        System.out.println(user.getName());
    }
}
